
package com.feib.soeasy.job.service;

import java.util.Date;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.feib.soeasy.model.ColumnValidateError;
import com.feib.soeasy.model.Group;
import com.feib.soeasy.model.MailQueue;
import com.feib.soeasy.model.Payment;
import com.feib.soeasy.model.UploadFile;


/**
 * @title (#)ImportService.java<br>
 * @description <br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/12/3 create by Jimmy Liu<br>
 */
@Transactional(readOnly = true)
public interface ImportService {

    /**
     * 以主鍵值取得待檢核資料<br>
     * UploadFile.fileStatus == UploadFile.FILE_STATUS_UN_CHECK
     * @param uploadFilePk
     * @return
     */
    public UploadFile getUnCheckUploadFileByPk(Long uploadFilePk);
    
    /**
     * 取得待檢核的第一筆資料<br>
     * UploadFile.fileStatus == UploadFile.FILE_STATUS_UN_CHECK
     * @return
     */
    public UploadFile getFirstUnCheckUploadFile();
    
    /**
     * 更新檔案狀態欄位
     */
    @Transactional(readOnly = false)
    public void updateUploadFileStatus(UploadFile uploadFile);

    /**
     * 刪除已新增的繳費單
     * @param uploadFile
     */
    @Transactional(readOnly = false)
    public void deletePaymentsByUploadFile(UploadFile uploadFile);

    /**
     * 新增繳費單到資料庫中
     * @param payments
     */
    @Transactional(readOnly = false)
    public void addPayments(List<Payment> payments);

    /**
     * @param columnValidateErrors
     */
    @Transactional(readOnly = false)
    public void addColumnValidateErrors(List<ColumnValidateError> columnValidateErrors);

    /**
     * 檢查繳費帳號是否重複
     * @param virtualAccount 虛擬帳號
     * @param payDue 繳費期限
     * @return
     */
    public boolean hasVirtualAccount(String virtualAccount, Date payDue);

    /**
     * 加入到Mail排程中
     * @param mailQueue
     * @return
     */
    @Transactional(readOnly = false)
    public MailQueue addMailQueue(MailQueue mailQueue);

    /**
     * 取得檔案錯誤原因
     * @param uploadFile
     * @return
     */
    public List<ColumnValidateError> getColumnValidateErrors(UploadFile uploadFile);
    
    /**
     * 取得同一個帳單業者可以執行整批放行權限的Email
     * @param group
     * @return
     */
    public List<String> getConfirmUserEmail(Group group);

    /**
     * 更新總筆數，總金額
     * @param uploadFile
     */
    public void updateUploadFileTotals(UploadFile uploadFile);
}
